<!DOCTYPE html>
<html>
    <head>
        <title>使用form对象实现Web页面信息交互</title>
        <script>
            function check(){
               // var input_obj = document.getElementByIdName("name1")
               //var agree_obj = document.getElementByIdName("agree")
                //if(input_obj[0].value.length == 0 || agree_obj[0].checked == false)
                if(window.document.form1.name1.value.length == 0 &&  window.document.form1.agree.checked == false)
                alert("姓名不能为空且必须接受协议！");
                return true;
            }
        
            function set(){
                if (confirm("真的清除吗？"))
                return true;
                else
                return false;

            }
        </script>
    </head>
    <body>
        <form name="form1"  action=""  method="post"  onsubmit="return check()"  onreset="return set()">
            请输入姓名:<input type="text" name="name1" size="16"><br>
            接受商城协议<input type="checkbox" name="agree"><br>
            <input type="submit" value="提交">
            <input type="reset" value="复位">

        </form>
    </body>
</html>